<?php


namespace Hx;

abstract class Di {

    protected function set($name, $call, $useConfig = FALSE) {
        if ($call instanceof \Closure) {
            $prop = call_user_func($call);
        } elseif (is_object($call)) {
            $prop = $call;
        } else {
            $call = explode(':', $call);
            $prop = App::getInstance()->getClass($call[0], $call[1], $useConfig);
        }
        $this->{$name} = $prop;
        return $this->{$name};
    }


    /*
    protected function get($name) {
        return $this->{$name};
    }

    public function __call($name, $value) {
        if (stripos($name, 'set') === 0) {
            $propName = ltrim($name, 'set');
            $propName[0] = strtolower($propName[0]);
            $this->set($propName, $value[0]);
            return NULL;
        }
        if (stripos($name, 'get') === 0) {
            $propName = ltrim($name, 'get');
            $propName[0] = strtolower($propName[0]);
            return $this->{$propName};
        }
        return NULL;
    }
    */


}